<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <meta charset="UTF-8">
  <script>
    function insert(value) {
      if (value === 'C') {
        document.getElementById('inputText').value = ''
      } else if (value === '←') {
        var input = document.getElementById('inputText').value
        document.getElementById('inputText').value = input.slice(0, -1)
      } else {
        document.getElementById('inputText').value += value
      }
    }
    function equal() {
      var input = document.getElementById('inputText').value
      try {
        var exp = input.replace(/(\d+\.\d+|\d+)/g, function (match) {
          return Number(match).toFixed(15)
        });
        var result = eval(exp)
        result = Number(result).toFixed(15)
        document.getElementById('inputText').value = result
      } catch (error) {
        document.getElementById('inputText').value = 'ERROR'
      }
    }
  </script>
  <style>
    body {
      font-family: Arial, sans-serif
    }
    input[type="text"] {
      width: 225px;
      height: 40px;
      font-size: 20px;
      margin-bottom: 10px;
    }
    button {
      width: 70px;
      height: 40px;
      font-size: 18px;
      margin: 2px;
	cursor: pointer;
    }
  </style>
</head>

	<body>
	<input type="text" id="inputText" readonly>
	<button onclick="insert('←')">←</button><br>
	<button onclick="insert('C')">C</button>
	<button onclick="insert('(')">(</button>
	<button onclick="insert(')')">)</button>
	<button onclick="insert('%')">%</button><br>
	<button onclick="insert('7')">7</button>
	<button onclick="insert('8')">8</button>
	<button onclick="insert('9')">9</button>
    <button onclick="insert('+')">+</button><br>
	<button onclick="insert('4')">4</button>
	<button onclick="insert('5')">5</button>
	<button onclick="insert('6')">6</button>
	<button onclick="insert('-')">-</button><br>
	<button onclick="insert('1')">1</button>
	<button onclick="insert('2')">2</button>
	<button onclick="insert('3')">3</button>
	<button onclick="insert('*')">*</button><br>
	<button onclick="insert('0')">0</button>
	<button onclick="insert('.')">.</button>
	<button onclick="equal()">=</button>
	<button onclick="insert('/')">/</button>
	</body>
</html>